<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<?php
session_start();
if (empty($_SESSION["loginusername"])) {
                            Header("Location: firstphp.php");
                        }
if (!empty($_SESSION["userType"])) {
    $userType = $_SESSION["userType"];
}
?>

<html>
    <?php
    echo "
<head>
<title>Reports</title>";
    ?>
    <link rel="stylesheet" href="http://localhost/Eldercare/jquery/jquery-ui.css" />
    <script src="http://localhost/Eldercare/jquery/jquery-1.9.1.js"></script>
    <script src="http://localhost/Eldercare/jquery/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />
    <link href="http://localhost/Eldercare/finalstyle.css" rel="stylesheet" type="text/css" media="all" />
    <script>
        var url
        $(function() {
            $("#datepicker").datepicker();
        });
        $(function() {
            $("#datepicker1").datepicker();
        });
        function email()
        {
            alert('Email Sent!');
        }
    </script>	
</head>
<style type="text/css">
    body {
        background: #FFFFFF url("images/bg.png") repeat;
        background-attachment:fixed;
    }
    .button 
    {
        background-color:beige;
        cursor:pointer; }

    .btn
    {
        background-color:#FFF5EE;
        cursor:pointer;
    }

</style>
<body>
    <ul>
        <div class="banner"></div>
        <div id="main">
            <div class="left-wrapper">
                <div class="logo">
                </div>
                <div class="menu-wrapper">
                    <div id='cssmenu' >     
                        <ul>
                            <?php
                                if ($userType == "Therapy Assistant") {
                                    //if TA
                                    echo "<li class='has-sub' class='active'><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance Taking</span></a></li>
			 <li class='last'><a href='http://localhost/Eldercare/ViewAttendanceRecord.php'><span>View Attendance</span></a></li>
			 </ul>
			  </li>
			  <li class='has-sub'><a href='#'><span>Profile</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Client.php'><span>Existing Client</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/WClient.php'><span>Withdrawn Client</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='http://localhost/Eldercare/ActRecords.php'><span>Activities</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ActRecords.php'><span>Activity Recording</span></a></li>
		 <li class='last'><a href='http://localhost/Eldercare/ViewActRecord.php'><span>View Activity Records</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='#'><span>Reports</span></a>
   <ul>
   <li><a href='http://localhost/Eldercare/Reports.php'><span>Attendance Reports</span></a></li>
   <li class='last'><a href='http://localhost/Eldercare/ActReports.php'><span>Activity Reports</span></a></li>
   </ul>
   </li>
   <li class='last'><a href='http://localhost/Eldercare/ManagePassword.php'><span>Change Passwords</span></a></li>
     
			 ";
                                } else if ($userType == "Centre Manager") {
                                    echo "
			<li class='has-sub' class='active'><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance Taking</span></a></li>
			 <li><a href='http://localhost/Eldercare/ViewAttendanceRecord.php'><span>View Attendance</span></a></li>
			<li><a href='http://localhost/Eldercare/BackDate.php'><span>BackDate</span></a></li>
			<li class='last'><a href='http://localhost/Eldercare/VerifyAttendance.php'><span>Verify Attendance</span></a></li>
			</ul>
			<li class='has-sub'><a href='#'><span>Profile</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Client.php'><span>Existing Client</span></a></li>
         <li><a href='http://localhost/Eldercare/WClient.php'><span>Withdrawn Client</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/User.php'><span>User</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='http://localhost/Eldercare/ActRecords.php'><span>Activities</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ActRecords.php'><span>Activity Recording</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ViewActRecord.php'><span>View Activity Records</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='#'><span>Reports</span></a>
   <ul>
   <li><a href='http://localhost/Eldercare/Reports.php'><span>Attendance Reports</span></a></li>
   <li class='last'><a href='http://localhost/Eldercare/ActReports.php'><span>Activity Reports</span></a></li>
   </ul>
   </li>
    <li class='has-sub'><a href='#'><span>Password</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ManagePassword.php'><span>Change Passwords</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ForgetPasswords.php'><span>Forget Password</span></a></li>
      </ul>
   </li>
			";
                                } else {
                                    echo "
			<li class='has-sub' class='active'><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance Taking</span></a></li>
			 <li><a href='http://localhost/Eldercare/ViewAttendanceRecord.php'><span>View Attendance</span></a></li>
			<li><a href='http://localhost/Eldercare/BackDate.php'><span>BackDate</span></a></li>
			<li class='last'><a href='http://localhost/Eldercare/VerifyAttendance.php'><span>Verify Attendance</span></a></li>
			</ul>
			<li class='has-sub'><a href='#'><span>Profile</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Client.php'><span>Existing Client</span></a></li>
         <li><a href='http://localhost/Eldercare/WClient.php'><span>Withdrawn Client</span></a></li>
         <li><a href='http://localhost/Eldercare/User.php'><span>User</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/Centres.php'><span>Centres</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='http://localhost/Eldercare/ActRecords.php'><span>Activities</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Activities.php'><span>Manage Current Activities</span></a></li>
         <li><a href='http://localhost/Eldercare/ActRecords.php'><span>Activity Recording</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ViewActRecord.php'><span>View Activity Records</span></a></li>
      </ul>
   </li>
   <li><a href='http://localhost/Eldercare/Holidays.php'><span>Holiday</span></a></li>
<li class='has-sub'><a href='#'><span>Reports</span></a>
   <ul>
   <li><a href='http://localhost/Eldercare/Reports.php'><span>Attendance Reports</span></a></li>
   <li class='last'><a href='http://localhost/Eldercare/ActReports.php'><span>Activity Reports</span></a></li>
   </ul>
   </li>
    <li class='has-sub'><a href='#'><span>Password</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ManagePassword.php'><span>Change Passwords</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ForgetPasswords.php'><span>Forget Password</span></a></li>
      </ul>
   </li>
			";
                                }
                                ?>
                        </ul>
                    </div>
                    <div class="clear"></div></div></div>
            <div class="content">
                <div class="content2">

                    <b style="float:right; margin: 0px 0 0 0">  <?php
                        if (!empty($_SESSION["sent"]) && ($_SESSION["sent"] == true)) {

                            echo "<script> email();</script>";
                            $_SESSION["sent"] = false;
                        }
                        ?><?php
                        //session_start();
                        if (!empty($_SESSION["centreName"])) {
                            $Username = $_SESSION["loginusername"];
                            $centreName = $_SESSION["centreName"];
                            echo "Welcome, " . $Username . " ! <br>" . $centreName . " Branch";
                        } else {
                            $Username = $_SESSION["loginusername"];
                            echo "Welcome, " . $Username;
                        }

                        

//session_start();
// set timeout period in seconds
                        $inactive = 7200;
// check to see if $_SESSION['timeout'] is set
                        if (isset($_SESSION["timeout"])) {
                            $session_life = time() - $_SESSION["timeout"];
                            if ($session_life > $inactive) {
                                session_destroy();
                                Header("Location: Timeout.php");
                            }
                        }
                        $_SESSION["timeout"] = time();
                        ?>
                        <!--<a href='logout.php'> Logout</a> -->
                        <input type="submit" class="button" value="Logout" onclick="parent.location = 'logout.php'"></b>
                    </p>
                    <br>
                    <h3>Attendance Reports</h3>
                    <p> <form name="reportdates" method="POST"><b>From: </b> <input type="date" name="startDate" value=<?php date('d-m-Y') ?> /><b>&nbsp; &nbsp; To: </b> <input type="date" name="endDate"  />


                        <?php
                        if ($userType == "System Admin") {
                            echo"
<b> &nbsp; &nbsp; Center: </b>

<select name='ddlCentre'>
	<option value='0'selected >All</option>";

                            mysql_connect("localhost", "root", "");
                            mysql_select_db("eldercaredb");
                            $centreDetail = "SELECT CentreId, CentreName FROM centre";
                            $query_result = mysql_query($centreDetail);
                            while ($result = mysql_fetch_assoc($query_result)) {

                                echo "<option value=";
                                echo $result['CentreId'];
                                echo">";
                                echo $result['CentreName'];
                                echo"</option>";
                            }

                            echo"</select>
";
                        }
                        ?>
                        <input type="submit" button class="btn"id="submit" value ='Submit'name="submit"/></form>



                    </p>
                    <p></p>
                    <p>
                        <?php
                        if (isset($_POST['submit'])) {
                            if (isset($_POST['startDate'])) {
                                if (date('Y-m-d', strtotime($_POST['startDate'])) != '1970-01-01') {
                                    if (isset($_POST['endDate'])) {
                                        $startDate = date('Y-m-d',strtotime($_POST['startDate']));
                                        $endDate = date('Y-m-d',strtotime($_POST['endDate']));
                                        if(!($endDate<$startDate)){
                                        if (date('Y-m-d', strtotime($_POST['endDate'])) != '1970-01-01') {
                                            include_once('Reports/createdatetable.php');
                                        } else {
                                                echo "<font color=red>Please pick two dates!</font>";
                                        }
                                        }
                                        else
                                        {
                                            echo "<font color=red>The date range is invalid! Please select again.</font>";
                                        }
                                    }
                                } else {
                                    echo "<font color=red>Please pick two dates!</font>";
                                }
                            }
                        }
                        //mail("nethmi_girl@hotmail.com","test subject","test body");
                        ?>



                </div><div class="clear"></div></div>
        </div>
</body> <div class="clear"></div>

</html>

